<template>
  <j-modal
    :title="'报表上报'"
    :width="800"
    :visible="visible"
    :maskClosable="false"
    :ok-button-props="{ props: { disabled: disableSubmit } }"
    :fullscreen="true"
    @close="close"
    cancelText="关闭"
  >
    <template slot="footer">
      <a-button key="back" style="padding-left: 8px; padding-right: 8px" @click="close(false)"> 关闭</a-button>
      <a-popconfirm :disabled="disableSubmit" title="确定保存吗?" @confirm="() => saveOrSubmit('save', null)">
        <a-button key="save" style="padding-left: 8px; padding-right: 8px" :disabled="disableSubmit"> 保存</a-button>
      </a-popconfirm>
      <a-button
        key="submit"
        type="primary"
        style="padding-left: 8px; padding-right: 8px"
        :disabled="disableSubmit"
        @click="close(true)"
      >
        提交审批
      </a-button>
    </template>
    <a-spin :spinning="Loading">
      <div :class="{ isCheck: isCheck }">
        <!-- <div class="table-header">
          <span class="table-title">填报单位：</span>{{ model.departName }} <span class="table-title">审计负责人：</span
          >{{ model.auditPersonName }} <span class="table-title">填表人：</span>{{ model.createByText }}
          <span class="table-title">填表时间：</span>{{ model.createTime }} <span class="table-title">统计时间：</span
          >{{ model.year }}年（{{ model.quarter }}季度）
        </div> -->
        <a-table
          class="edit-list"
          ref="table"
          size="middle"
          rowKey="id"
          bordered
          width="100vw"
          :pagination="false"
          :columns="columns"
          :dataSource="dataSource"
          :scroll="{ x: 250, y: 520 }"
        >
          <!-- <template slot="customTitle">
            <div class="header-title">工作单位</div>
          </template> -->
          <div slot="title">
            <div class="title">{{ title }}</div>
            <div class="sub-title">
              <div>填报单位：{{ model.departName }}</div>
              <div>{{ model.year }}年（{{ model.quarter }}季）度</div>
              <div>
                审计负责人：
                <fzrSelect :disabled="disableSubmit" v-model="model.head"></fzrSelect>
              </div>
              <div>填表人：{{ model.createByText }}</div>
              <div>填表时间：{{ model.createTime }}</div>
              <div>金额单位（万元）</div>
            </div>
          </div>
          <template slot="unit" slot-scope="unit">
            <!-- <j-ellipsis :value="unit" :length="25"/> -->
            <div style="width: 100%; height: 45px; overflow-x: hidden; overflow-y: auto">{{ unit }}</div>
          </template>
          <template slot="honor" slot-scope="honor">
            <div style="width: 100%; height: 45px; overflow-x: hidden; overflow-y: auto">{{ honor }}</div>
          </template>
          <template slot="honor1" slot-scope="honor1">
            <div style="width: 100%; height: 45px; overflow-x: hidden; overflow-y: auto">{{ honor1 }}</div>
          </template>
          <template slot="system" slot-scope="system">
            <div style="width: 100%; height: 45px; overflow-x: hidden; overflow-y: auto">{{ system }}</div>
          </template>
          <template slot="paper" slot-scope="paper">
            <div style="width: 100%; height: 45px; overflow-x: hidden; overflow-y: auto">{{ paper }}</div>
          </template>

          <template slot="paper1" slot-scope="paper1">
            <div style="width: 100%; height: 45px; overflow-x: hidden; overflow-y: auto">{{ paper1 }}</div>
          </template>
          <template slot="system1" slot-scope="system1">
            <div style="width: 100%; height: 45px; overflow-x: hidden; overflow-y: auto">{{ system1 }}</div>
          </template>

          <template slot="workYear" slot-scope="workYear, record">
            <div>{{ isNaN(Number(workYear)) ? workYear : record.workYear_dictText }}</div>
          </template>

          <template slot="auditPeriod" slot-scope="auditPeriod, record">
            <div>{{ isNaN(Number(auditPeriod)) ? auditPeriod : record.auditPeriod_dictText }}</div>
          </template>
        </a-table>
        <div
          class="uploadFile"
          style="height: 40px; line-height: 40px; position: relative; margin-top: 10px; width: 97vw"
        >
          <span style="font-size: 16px" v-if="disableSubmit">说明性文件:</span>
          <ZUpload
            style="position: absolute; left: 120px; width: 92%"
            :disabled="disableSubmit"
            :isShow="disableSubmit"
            ref="fileUpload"
            :fileid="model.fileId"
            @uploadFile="saveData"
            :isScroll="true"
          ></ZUpload>
        </div>
      </div>
    </a-spin>

    <SelectApprove ref="approver" @submitData="saveOrSubmit"></SelectApprove>
  </j-modal>
</template>
<script>
import columns from './columns5'
import SelectApprove from '../SelectApprover'
import fzrSelect from '../fzrSelect'

import ZUpload from '../../../components/ZUpload'
import { deleteAction } from '@/api/manage'
import { BbsbModelMixin2 } from './BbsbModelMixin2'

export default {
  name: 'ModelView5',
  mixins: [BbsbModelMixin2],
  components: {
    SelectApprove,
    ZUpload,
    fzrSelect,
  },
  data() {
    return {
      columns: columns(this),
      model: {},
      btnStyle: 'save',
      approveId: '',
      sjType: '3',
      url: {
        list: '/sjxxzhbb/sjAuditInfo/getAuditInfoDetails',
        getCreatData: '/sjxxzhbb/sjAuditInfo//queryInternalAuditInfo',
        add: '/sjxxzhbb/sjAuditInfo/add',
        edit: '/sjxxzhbb/sjAuditInfo/edit',
        delete: '/sjxxzhbb/sjAuditInfo/remove',
        submitData: '/common/sjProcCommon/auditShen',
      },
    }
  },
  created() {},
  methods: {
    // 保存或提交
    saveOrSubmit(style, approveId) {
      this.btnStyle = style
      this.approveId = approveId
      this.$refs.fileUpload.saveFile('nbsjrypzqkb')
    },
    delete(record) {
      deleteAction(this.url.delete, { id: record.id }).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.$emit('ok')
        } else {
          this.$message.error(res.message)
        }
      })
    },
  },
}
</script>

<style lang="less" scoped>
// @import '../../../css/checkAndEdit.less';
@import '../../css/baobiaotable.less';

.table-header {
  margin-bottom: 10px;

  .table-title {
    font-weight: bold;
    margin-left: 15px;
  }
}

.edit-list {
  .header-title {
    height: 106px;
    text-align: center;
    line-height: 106px;
  }
}
</style>
